package com.ciaojian.core.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.ciaojian.core.enums.business.ScheduleTypeEnum;
import com.ciaojian.core.enums.business.WorkerApplyStatusEnum;
import com.ciaojian.core.model.group.Save;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.sql.Time;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 排班表
 * </p>
 *
 * @author Atlakyn
 * @since 2021-03-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("d_scheduling")
public class Scheduling extends Model<Scheduling> {
    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @Null(message = "禁止传入id", groups = Save.class)
    private Long id;

    @ApiModelProperty(value = "发型师id", required = true)
    @NotNull(message = "发型师id不能为空", groups = Save.class)
    private Integer workerId;

    @ApiModelProperty(value = "发型师姓名", required = true)
    @NotBlank(message = "发型师姓名不能为空", groups = Save.class)
    private String name;

    @ApiModelProperty(value = "门店id", required = true)
    @NotNull(message = "门店Id不能为空", groups = Save.class)
    private Integer storeId;

    @ApiModelProperty(value = "门店名称", required = true)
    @NotBlank(message = "门店名称不能为空", groups = Save.class)
    private String storeName;

    @ApiModelProperty(value = "发型师手机号", required = true)
    @NotBlank(message = "发型师手机号不能为空", groups = Save.class)
    @Pattern(regexp = "1[3|4|5|7|8][0-9]\\d{8}", message = "手机号格式错误")
    private String phone;

    @ApiModelProperty(value = "班次Id", required = true)
    private Integer rosterId;

    @ApiModelProperty(value = "班次", required = true)
    private String droster;

    @ApiModelProperty(value = "日期", required = true)
    @NotNull(message = "日期不能为空", groups = Save.class)
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Future(message = "排班日期有误", groups = Save.class)
    private Date date;

    @ApiModelProperty(value = "审核状态: 0待审核-1审核通过-2审核驳回", hidden = true)
    @Null(groups = Save.class, message = "禁止传入 status")
    private WorkerApplyStatusEnum status;

    @ApiModelProperty("日程类型")
    @NotNull(message = "请选择日程类型", groups = Save.class)
    private ScheduleTypeEnum type;

    @ApiModelProperty("排班审核ID")
    private Long examineId;

    @ApiModelProperty("第一次就餐开始时间")
    private Time lunchStartTime;

    @ApiModelProperty("第一次就餐结束时间")
    private Time lunchEndTime;

    @ApiModelProperty("第二次就餐开始时间")
    private Time dinnerStartTime;

    @ApiModelProperty("第二次就餐结束时间")
    private Time dinnerEndTime;

    @ApiModelProperty("创建时间")
    @Null(groups = Save.class, message = "禁止传入创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "逻辑删除", hidden = true)
    private Boolean logicDel;

    @ApiModelProperty("是否请半天 0上半天 1下半天")
    private Integer half;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
